from RSpider.mysqlConnection import getPTConnection

def insertData(item):
    #申请资源
    with getPTConnection() as db:

        # SQL 查询语句;
        sql = "INSERT into cra_task_log_back(id,c_batch,c_url,create_time,end_time,c_content,c_title,b_parse_status,hash_code) " \
              "VALUES('{}','{}','{}',NOW(),NOW(),'{}','{}',0,'{}')"\
            .format(item['id'],item['cBatch'],item['c_Url'],item['c_content'],item['c_title'],item['hashcode'])
        print(sql)
        try:
            # 获取所有记录列表
            db.cursor.execute(sql)
            db.conn.commit()
        except Exception as e:
            print (e)

